In this analysis I used real data from Brazil Stock Market.

I will create a R package called r-stock-analysis https://github.com/caiomsouza/r-stock-analysis

http://www.thertrader.com

http://www.thertrader.com/2014/02/28/using-cart-for-stock-market-forecasting/

https://cran.r-project.org/web/packages/stocks/index.html

https://www.youtube.com/watch?v=iMET2gbsbHY

http://www.r-chart.com/2010/06/stock-analysis-using-r.html

# UCM
# Prof. Lorenzo Escot
# Alumno: Caio Fernandes Moreno (caiofern@ucm.es)
# Brazil Stock Market Analysis




setwd("~/git/Bitbucket/ucm/SCORE/tareas/Lorenzo-Escot")

library(tseries) # adf.test, kpss.test, bds.test, get.hist.quote, portfolio.optim, surrogate, arma, garch
#install.packages("forecast")
library(forecast)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Loading required package: timeDate
## This is forecast 6.2
# En el paquete forecast tiene un modelo auto ARIMA.
#install.packages("fArma")
library(fArma) #ARMAFIT, RSFIT
## Loading required package: timeSeries
## 
## Attaching package: 'timeSeries'
## 
## The following object is masked from 'package:zoo':
## 
##     time<-
## 
## Loading required package: fBasics
## 
## 
## Rmetrics Package fBasics
## Analysing Markets and calculating Basic Statistics
## Copyright (C) 2005-2014 Rmetrics Association Zurich
## Educational Software for Financial Engineering and Computational Science
## Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
## https://www.rmetrics.org --- Mail to: info@rmetrics.org
#install.packages("fGarch")
library(fGarch) #GARCHFIT formula ~arma (2,1) + garch (1,1) # ~ AltGr + 4
#install.packages("outliers")
library(outliers) #: outlier, rm.outlier, scores, chisq.out.test # para detectar outliers o datos an?malos ojo serie estacionaria
## 
## Attaching package: 'outliers'
## 
## The following object is masked from 'package:timeSeries':
## 
##     outlier
#install.packages("zoo")
library(zoo)
#setinternet2() #esto abre el puerto de internet



#stock.name <- "^BVSP"
#stock.description <- "IBOVESPA"



generateAnalysis <- function(x, y) {
  

stock.name <- x 
stock.description <- y  
  
  
## lectura de los datos hist?ricos del ^BVSP
stock.name <- get.hist.quote(instrument=stock.name, quote="AdjClose")

# BVSP time series starts 1993-04-27
# http://finance.yahoo.com/q?s=%5EBVSP

series.name <- stock.name

str(series.name)
summary(series.name)
start(series.name)
end(series.name)
plot(series.name)

head(series.name, 10)

tail(series.name, 10)

# Mirando los datos he decidido con la ayuda del Prof. Lorenzo no quitar los datos de 1993 hasta 1998.

#?existen datos nulos?
length(series.name)
length(series.name[!is.na(series.name)])
length(complete.cases(series.name))
#parece que no, pero si tuviera na se podr?an quitar con: ibex<-ibex[complete.cases(ibex)]

series.name<-series.name[complete.cases(series.name)]
plot(series.name)


### podemos seleccionar una submuestra: Temporal
series.name.short <-window(series.name,start=as.Date("1993-04-27"),end=as.Date("2015-09-30"))
str(series.name.short)
summary(series.name.short)
plot(series.name.short)


## Calculo la serie de rendimientos
d.series.name <- diff(log(series.name.short))

# Concatenate stock.description with the text Withall
plot.description <- paste(stock.description, "WITH ALL DATA", collapse = ", ")

#Grafico de la serie 
plot(d.series.name, main=(plot.description))

     

     
#Datos an?malos
# type = z Busca los datos tipificados mayor que 5 vezes la sd (disviacion tipica)

# Remove datos anomalos
remove.outlier.d.series.name <- d.series.name[abs(scores(d.series.name, type="z"))<=5]

#plot(remove.outlier.d.series.name, main="IBOVESPA WITHOUT OUTLIERS")

# Concatenate stock.description with the text Withall
plot.description <- paste(stock.description, " WITHOUT OUTLIERS", collapse = ", ")

#Grafico de la serie 
plot(d.series.name, main=(plot.description))


#?es estacionario?
adf.test(d.series.name)# Ho: una ra?z unitaria (no estacionaria)

# Augmented Dickey-Fuller Test
# data:  dBVSP
# Dickey-Fuller = -14.073, Lag order = 17, p-value = 0.01
# alternative hypothesis: stationary

# No es estacionaria

sd(d.series.name) #desviaci?n t?pica

# Statistical stationarity:
# http://people.duke.edu/~rnau/411diff.htm


#?presenta correlaci?n?

df.d.series.name <- as.data.frame(d.series.name)

#periodograma
par(mfrow=c(2,1))
acf(df.d.series.name, ylim=c(-1,1)) 
pacf(df.d.series.name, ylim=c(-1,1))


tsdisplay(df.d.series.name)


# test bds
bds.test(d.series.name,m=10) # H0: i.i.d

#test R/, exponente de Hurst
HURST<-rsFit(d.series.name, doplot = T)# Exponente de Hurst 0.5 ruido blanco
HURST

##Se puede hacer el test de Hurst=0.5 con el siguiente estad?stico t ## 

t<-(HURST@hurst$diag[2,1]-0.5)/HURST@hurst$diag[2,2]
t

#Modelo Auto Arima

modelo.auto.arima <- auto.arima(d.series.name)
plot(forecast(modelo.auto.arima,h=20))


modelo.auto.arima1 <- auto.arima(d.series.name)
plot(forecast(modelo.auto.arima1, h=1))


# alternativa
d.series.name.ARMA<-armaFit(~ arma(1,3), data=d.series.name)
summary(d.series.name.ARMA, wich="all")
residuo<-residuals(d.series.name.ARMA)


plot(residuo)
lines(residuo)

df.residuo <- as.data.frame(residuo)

#periodograma
par(mfrow=c(2,1))
acf(df.residuo, ylim=c(-1,1)) 
pacf(df.residuo, ylim=c(-1,1))

#x11()
tsdisplay(df.residuo)


# test bds
bds.test(d.series.name,m=10) # H0: i.i.d

#test R/, exponente de Hurst
HURST<-rsFit(d.series.name, doplot = T)# Exponente de Hurst 0.5 ruido blanco
HURST


# Este codigo ha tenido muchas modificaciones hay que cojer el codigo del profesor Lorenzo.

##Se puede hacer el test de Hurst=0.5 con el siguiente estad?stico t ## 

t<-(HURST@hurst$diag[2,1]-0.5)/HURST@hurst$diag[2,2]
t


####PREDICCIONES
predict(d.series.name.ARMA, n.ahead=10, conf=c(90,95), dplot=True)


#alternativo
d.series.name.ARMAGARCH<-garchFit(~ arma(1,1) + garch(2,1), data=d.series.name, include.mean=TRUE) ####aqu? el orden es GARCH,ARCH
summary(d.series.name.ARMAGARCH)
plot(d.series.name.ARMAGARCH@residuals)
residuogarch<-residuals(d.series.name.ARMAGARCH)
volatilitygarch<-volatility(d.series.name.ARMAGARCH)
plot(volatilitygarch)
lines(volatilitygarch)
plot(d.series.name^2)

predict(d.series.name.ARMAGARCH, n.ahead=10, conf=c(90,95), dplot=TRUE)


}



# IBOVESPA
stock.name <- "^BVSP"
stock.description <- "IBOVESPA"
# Call your function and pass x and y to the function
run <- generateAnalysis(stock.name,stock.description)
## time series starts 1993-04-27
## 'zoo' series from 1993-04-27 to 2015-11-16
##   Data: num [1:5603, 1] 24.5 24.3 23.7 24.1 24.1 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr "AdjClose"
##   Index:  Date[1:5603], format: "1993-04-27" "1993-04-28" "1993-04-29" "1993-04-30" ...

## 'zoo' series from 1993-04-27 to 2015-09-30
##   Data: num [1:5572] 24.5 24.3 23.7 24.1 24.1 ...
##   Index:  Date[1:5572], format: "1993-04-27" "1993-04-28" "1993-04-29" "1993-04-30" ...

## Warning in adf.test(d.series.name): p-value smaller than printed p-value

## Warning in sqrt(diag(fit$var.coef)): NaNs produced

## 
## Title:
##  ARIMA Modelling 
## 
## Call:
##  armaFit(formula = ~arma(1, 3), data = d.series.name)
## 
## Model:
##  ARIMA(1,0,3) with method: CSS-ML
## 
## Coefficient(s):
##       ar1        ma1        ma2        ma3  intercept  
##  0.028451   0.027562  -0.006066  -0.012289   0.001349  
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.1724656 -0.0116332 -0.0002197  0.0116098  0.2916280 
## 
## Moments: 
## Skewness Kurtosis 
##   0.5518  10.4767 
## 
## Coefficient(s):
##             Estimate  Std. Error  t value Pr(>|t|)    
## ar1        0.0284509          NA       NA       NA    
## ma1        0.0275620          NA       NA       NA    
## ma2       -0.0060665          NA       NA       NA    
## ma3       -0.0122894   0.0034857   -3.526 0.000422 ***
## intercept  0.0013495   0.0003251    4.151 3.31e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## sigma^2 estimated as: 0.0005446
## log likelihood:       13029.24
## AIC Criterion:        -26046.48

## 
## Description:
##  Tue Nov 17 20:59:57 2015 by user:

## 
## Series Initialization:
##  ARMA Model:                arma
##  Formula Mean:              ~ arma(1, 1)
##  GARCH Model:               garch
##  Formula Variance:          ~ garch(2, 1)
##  ARMA Order:                1 1
##  Max ARMA Order:            1
##  GARCH Order:               2 1
##  Max GARCH Order:           2
##  Maximum Order:             2
##  Conditional Dist:          norm
##  h.start:                   3
##  llh.start:                 1
##  Length of Series:          5571
##  Recursion Init:            mci
##  Series Scale:              0.02337828
## 
## Parameter Initialization:
##  Initial Parameters:          $params
##  Limits of Transformations:   $U, $V
##  Which Parameters are Fixed?  $includes
##  Parameter Matrix:
##                      U           V      params includes
##     mu     -0.57716768   0.5771677  0.05772286     TRUE
##     ar1    -0.99999999   1.0000000 -0.04584008     TRUE
##     ma1    -0.99999999   1.0000000  0.10215077     TRUE
##     omega   0.00000100 100.0000000  0.10000000     TRUE
##     alpha1  0.00000001   1.0000000  0.05000000     TRUE
##     alpha2  0.00000001   1.0000000  0.05000000     TRUE
##     gamma1 -0.99999999   1.0000000  0.10000000    FALSE
##     gamma2 -0.99999999   1.0000000  0.10000000    FALSE
##     beta1   0.00000001   1.0000000  0.80000000     TRUE
##     delta   0.00000000   2.0000000  2.00000000    FALSE
##     skew    0.10000000  10.0000000  1.00000000    FALSE
##     shape   1.00000000  10.0000000  4.00000000    FALSE
##  Index List of Parameters to be Optimized:
##     mu    ar1    ma1  omega alpha1 alpha2  beta1 
##      1      2      3      4      5      6      9 
##  Persistence:                  0.9 
## 
## 
## --- START OF TRACE ---
## Selected Algorithm: nlminb 
## 
## R coded nlminb Solver: 
## 
##   0:     7007.5070: 0.0577229 -0.0458401 0.102151 0.100000 0.0500000 0.0500000 0.800000
##   1:     6912.5211: 0.0577222 -0.0462831 0.101731 0.0745310 0.0495072 0.0487042 0.786314
##   2:     6853.3005: 0.0577207 -0.0470350 0.101025 0.0634282 0.0685389 0.0667259 0.791504
##   3:     6836.3228: 0.0577203 -0.0472069 0.100865 0.0568509 0.0683983 0.0664953 0.789530
##   4:     6820.2471: 0.0577188 -0.0477502 0.100360 0.0438816 0.0716566 0.0695678 0.788959
##   5:     6812.6945: 0.0577096 -0.0502291 0.0980834 0.0378664 0.0817180 0.0812599 0.810664
##   6:     6805.5983: 0.0576893 -0.0540431 0.0946779 0.0164254 0.0748376 0.0771232 0.825021
##   7:     6794.9712: 0.0575556 -0.0718150 0.0795594 0.0237874 0.0753770 0.0716922 0.836102
##   8:     6788.5061: 0.0574791 -0.0557498 0.0969688 0.0199860 0.0745192 0.0629286 0.846183
##   9:     6787.9674: 0.0574787 -0.0557881 0.0969381 0.0190952 0.0740933 0.0624548 0.845810
##  10:     6787.5205: 0.0574688 -0.0566813 0.0962259 0.0199000 0.0719904 0.0593221 0.848100
##  11:     6787.4584: 0.0574596 -0.0573165 0.0957600 0.0170137 0.0729269 0.0590613 0.851498
##  12:     6786.9905: 0.0574435 -0.0578171 0.0955500 0.0178711 0.0729353 0.0566919 0.855337
##  13:     6786.3007: 0.0574238 -0.0583268 0.0953934 0.0166574 0.0727417 0.0533564 0.858240
##  14:     6785.0358: 0.0573042 -0.0609257 0.0949264 0.0147055 0.0756105 0.0374833 0.873206
##  15:     6784.9513: 0.0573039 -0.0609300 0.0949275 0.0144428 0.0754729 0.0373121 0.873049
##  16:     6784.9178: 0.0573005 -0.0609769 0.0949412 0.0148881 0.0752191 0.0367046 0.872989
##  17:     6784.8955: 0.0572891 -0.0610873 0.0950334 0.0148109 0.0757447 0.0361657 0.872897
##  18:     6784.8194: 0.0572043 -0.0618735 0.0957554 0.0150197 0.0791459 0.0331976 0.872542
##  19:     6784.8080: 0.0569791 -0.0636508 0.0980053 0.0146289 0.0789961 0.0327952 0.872790
##  20:     6784.7182: 0.0567522 -0.0654953 0.100181 0.0148012 0.0789341 0.0327467 0.873255
##  21:     6784.2295: 0.0518477 -0.109835 0.139305 0.0136174 0.0757387 0.0313714 0.878754
##  22:     6784.1406: 0.0511277 -0.113360 0.147435 0.0135018 0.0758185 0.0301757 0.880208
##  23:     6784.0039: 0.0503543 -0.116973 0.149390 0.0138244 0.0803689 0.0257012 0.879560
##  24:     6784.0031: 0.0503540 -0.116965 0.149401 0.0137353 0.0804061 0.0256993 0.879575
##  25:     6784.0014: 0.0503509 -0.116926 0.149379 0.0137706 0.0804440 0.0256933 0.879620
##  26:     6784.0006: 0.0503467 -0.116889 0.149364 0.0137362 0.0804623 0.0256583 0.879637
##  27:     6783.9995: 0.0503375 -0.116818 0.149332 0.0137450 0.0805052 0.0256090 0.879689
##  28:     6783.9886: 0.0501455 -0.115640 0.148781 0.0136994 0.0808562 0.0245808 0.880245
##  29:     6783.9846: 0.0500002 -0.113680 0.146786 0.0136566 0.0810501 0.0244768 0.880418
##  30:     6783.9807: 0.0498245 -0.112089 0.145224 0.0135753 0.0811067 0.0244143 0.880404
##  31:     6783.9734: 0.0488638 -0.107401 0.141045 0.0136648 0.0811885 0.0248538 0.879887
##  32:     6783.9621: 0.0482468 -0.0977786 0.130713 0.0134019 0.0819212 0.0235134 0.880859
##  33:     6783.9523: 0.0474507 -0.105218 0.138210 0.0134022 0.0835961 0.0203012 0.882299
##  34:     6783.9500: 0.0474507 -0.105220 0.138209 0.0132982 0.0835712 0.0202772 0.882257
##  35:     6783.9484: 0.0474539 -0.105285 0.138273 0.0133313 0.0835901 0.0203023 0.882275
##  36:     6783.9481: 0.0474599 -0.105422 0.138394 0.0132626 0.0836327 0.0203670 0.882278
##  37:     6783.9477: 0.0474707 -0.105728 0.138694 0.0132844 0.0836298 0.0204006 0.882266
##  38:     6783.9464: 0.0475954 -0.110869 0.143667 0.0133533 0.0833928 0.0209793 0.881851
##  39:     6783.9463: 0.0474949 -0.108712 0.141564 0.0133731 0.0831606 0.0213533 0.881696
##  40:     6783.9463: 0.0477035 -0.113348 0.146237 0.0133731 0.0832319 0.0212893 0.881691
##  41:     6783.9463: 0.0475918 -0.111389 0.144202 0.0133688 0.0832613 0.0212018 0.881746
##  42:     6783.9463: 0.0475979 -0.111229 0.144069 0.0133695 0.0832390 0.0212428 0.881729
##  43:     6783.9463: 0.0476014 -0.111364 0.144201 0.0133697 0.0832420 0.0212388 0.881730
## 
## Final Estimate of the Negative LLH:
##  LLH:  -14140.44    norm LLH:  -2.538223 
##            mu           ar1           ma1         omega        alpha1 
##  1.112838e-03 -1.113636e-01  1.442007e-01  7.307105e-06  8.324200e-02 
##        alpha2         beta1 
##  2.123883e-02  8.817298e-01 
## 
## R-optimhess Difference Approximated Hessian Matrix:
##                   mu         ar1         ma1         omega        alpha1
## mu     -1.549541e+07 -10973.6813   4394.0775  1.001200e+08  8.825238e+03
## ar1    -1.097368e+04  -5220.4525  -5213.6790  2.855247e+05  1.579227e+02
## ma1     4.394078e+03  -5213.6790  -5232.8327  2.416058e+05  1.471186e+02
## omega   1.001200e+08 285524.6926 241605.8057 -3.215057e+12 -5.470996e+08
## alpha1  8.825238e+03    157.9227    147.1186 -5.470996e+08 -1.621422e+05
## alpha2  9.952543e+02    199.6427    198.0982 -5.611563e+08 -1.616199e+05
## beta1  -1.252181e+04   -309.0611   -291.8503 -7.660070e+08 -1.853151e+05
##               alpha2         beta1
## mu      9.952543e+02 -1.252181e+04
## ar1     1.996427e+02 -3.090611e+02
## ma1     1.980982e+02 -2.918503e+02
## omega  -5.611563e+08 -7.660070e+08
## alpha1 -1.616199e+05 -1.853151e+05
## alpha2 -1.659141e+05 -1.908219e+05
## beta1  -1.908219e+05 -2.369930e+05
## attr(,"time")
## Time difference of 0.2042372 secs
## 
## --- END OF TRACE ---
## 
## 
## Time to Estimate Parameters:
##  Time difference of 0.7860799 secs
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~arma(1, 1) + garch(2, 1), data = d.series.name, 
##     include.mean = TRUE) 
## 
## Mean and Variance Equation:
##  data ~ arma(1, 1) + garch(2, 1)
## <environment: 0x7fd9a33940e8>
##  [data = d.series.name]
## 
## Conditional Distribution:
##  norm 
## 
## Coefficient(s):
##          mu          ar1          ma1        omega       alpha1  
##  1.1128e-03  -1.1136e-01   1.4420e-01   7.3071e-06   8.3242e-02  
##      alpha2        beta1  
##  2.1239e-02   8.8173e-01  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##          Estimate  Std. Error  t value Pr(>|t|)    
## mu      1.113e-03   3.965e-04    2.807    0.005 ** 
## ar1    -1.114e-01   3.066e-01   -0.363    0.716    
## ma1     1.442e-01   3.060e-01    0.471    0.637    
## omega   7.307e-06   1.445e-06    5.056 4.29e-07 ***
## alpha1  8.324e-02   1.467e-02    5.673 1.41e-08 ***
## alpha2  2.124e-02   1.906e-02    1.114    0.265    
## beta1   8.817e-01   1.257e-02   70.121  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  14140.44    normalized:  2.538223 
## 
## Description:
##  Tue Nov 17 20:59:59 2015 by user:  
## 
## 
## Standardised Residuals Tests:
##                                 Statistic p-Value     
##  Jarque-Bera Test   R    Chi^2  383.587   0           
##  Shapiro-Wilk Test  R    W      NA        NA          
##  Ljung-Box Test     R    Q(10)  22.13172  0.01444747  
##  Ljung-Box Test     R    Q(15)  34.83257  0.002597619 
##  Ljung-Box Test     R    Q(20)  49.09035  0.0002985119
##  Ljung-Box Test     R^2  Q(10)  21.52159  0.0177362   
##  Ljung-Box Test     R^2  Q(15)  24.39986  0.05860695  
##  Ljung-Box Test     R^2  Q(20)  36.64023  0.01291958  
##  LM Arch Test       R    TR^2   23.01995  0.02755703  
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -5.073933 -5.065608 -5.073936 -5.071031

# Itau
stock.name <- "ITSA4.SA"
stock.description <- "Itausa - Investimentos Itau S.A"
# Call your function and pass x and y to the function
run <- generateAnalysis(stock.name,stock.description)
## time series starts 2000-01-03
## 'zoo' series from 2000-01-03 to 2015-11-16
##   Data: num [1:3952, 1] 1.18 1.07 1.15 1.17 1.17 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr "AdjClose"
##   Index:  Date[1:3952], format: "2000-01-03" "2000-01-04" "2000-01-05" "2000-01-06" ...

## 'zoo' series from 2000-01-03 to 2015-09-30
##   Data: num [1:3919] 1.18 1.07 1.15 1.17 1.17 ...
##   Index:  Date[1:3919], format: "2000-01-03" "2000-01-04" "2000-01-05" "2000-01-06" ...

## Warning in adf.test(d.series.name): p-value smaller than printed p-value

## Warning in sqrt(diag(fit$var.coef)): NaNs produced

## 
## Title:
##  ARIMA Modelling 
## 
## Call:
##  armaFit(formula = ~arma(1, 3), data = d.series.name)
## 
## Model:
##  ARIMA(1,0,3) with method: CSS-ML
## 
## Coefficient(s):
##        ar1         ma1         ma2         ma3   intercept  
## -0.4637719   0.4593908  -0.0346233  -0.0623858   0.0004736  
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.1513665 -0.0126110 -0.0003865  0.0120425  0.2207712 
## 
## Moments: 
## Skewness Kurtosis 
##    0.159    5.837 
## 
## Coefficient(s):
##             Estimate  Std. Error  t value Pr(>|t|)    
## ar1       -0.4637719          NA       NA       NA    
## ma1        0.4593908          NA       NA       NA    
## ma2       -0.0346233   0.0181061   -1.912 0.055845 .  
## ma3       -0.0623858   0.0161051   -3.874 0.000107 ***
## intercept  0.0004736   0.0003491    1.357 0.174921    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## sigma^2 estimated as: 0.0005501
## log likelihood:       9143.71
## AIC Criterion:        -18275.42

## 
## Description:
##  Tue Nov 17 21:00:06 2015 by user:

## 
## Series Initialization:
##  ARMA Model:                arma
##  Formula Mean:              ~ arma(1, 1)
##  GARCH Model:               garch
##  Formula Variance:          ~ garch(2, 1)
##  ARMA Order:                1 1
##  Max ARMA Order:            1
##  GARCH Order:               2 1
##  Max GARCH Order:           2
##  Maximum Order:             2
##  Conditional Dist:          norm
##  h.start:                   3
##  llh.start:                 1
##  Length of Series:          3918
##  Recursion Init:            mci
##  Series Scale:              0.02350146
## Warning in arima(.series$x, order = c(u, 0, v), include.mean =
## include.mean): possible convergence problem: optim gave code = 1

## Parameter Initialization:
##  Initial Parameters:          $params
##  Limits of Transformations:   $U, $V
##  Which Parameters are Fixed?  $includes
##  Parameter Matrix:
##                      U           V     params includes
##     mu     -0.19570454   0.1957045  0.0237639     TRUE
##     ar1    -0.99999999   1.0000000 -0.6683783     TRUE
##     ma1    -0.99999999   1.0000000  0.6584622     TRUE
##     omega   0.00000100 100.0000000  0.1000000     TRUE
##     alpha1  0.00000001   1.0000000  0.0500000     TRUE
##     alpha2  0.00000001   1.0000000  0.0500000     TRUE
##     gamma1 -0.99999999   1.0000000  0.1000000    FALSE
##     gamma2 -0.99999999   1.0000000  0.1000000    FALSE
##     beta1   0.00000001   1.0000000  0.8000000     TRUE
##     delta   0.00000000   2.0000000  2.0000000    FALSE
##     skew    0.10000000  10.0000000  1.0000000    FALSE
##     shape   1.00000000  10.0000000  4.0000000    FALSE
##  Index List of Parameters to be Optimized:
##     mu    ar1    ma1  omega alpha1 alpha2  beta1 
##      1      2      3      4      5      6      9 
##  Persistence:                  0.9 
## 
## 
## --- START OF TRACE ---
## Selected Algorithm: nlminb 
## 
## R coded nlminb Solver: 
## 
##   0:     5244.6725: 0.0237639 -0.668378 0.658462 0.100000 0.0500000 0.0500000 0.800000
##   1:     5240.4064: 0.0237641 -0.668205 0.658449 0.0940228 0.0490924 0.0485124 0.796838
##   2:     5236.5163: 0.0237650 -0.667397 0.658393 0.0862565 0.0587229 0.0554772 0.800032
##   3:     5234.8854: 0.0237652 -0.667228 0.658388 0.0827132 0.0577342 0.0541024 0.798482
##   4:     5233.5097: 0.0237665 -0.666010 0.658343 0.0765515 0.0634863 0.0570618 0.804114
##   5:     5230.7497: 0.0237709 -0.662894 0.657616 0.0630851 0.0618546 0.0488964 0.817938
##   6:     5226.5230: 0.0237763 -0.661226 0.654591 0.0571136 0.0630191 0.0417846 0.836713
##   7:     5217.1652: 0.0237971 -0.660020 0.638098 0.0245700 0.0624935 0.00561052 0.904468
##   8:     5216.7239: 0.0237972 -0.659920 0.638168 0.0253204 0.0629123 0.00593970 0.905034
##   9:     5216.5869: 0.0237975 -0.659334 0.638495 0.0251052 0.0628954 0.00517032 0.905337
##  10:     5216.3504: 0.0237982 -0.658168 0.639087 0.0251116 0.0634457 0.00406613 0.906561
##  11:     5215.9590: 0.0237999 -0.656019 0.639809 0.0242004 0.0645939 0.00112882 0.908289
##  12:     5215.8628: 0.0238041 -0.653236 0.639171 0.0243168 0.0654772 1.00000e-08 0.910029
##  13:     5215.5972: 0.0238111 -0.649561 0.637191 0.0234762 0.0647881 1.00000e-08 0.910454
##  14:     5215.0117: 0.0239052 -0.611742 0.598806 0.0255541 0.0608996 1.00000e-08 0.911091
##  15:     5214.3425: 0.0240029 -0.570998 0.563760 0.0225342 0.0656161 1.00000e-08 0.912556
##  16:     5213.8395: 0.0241141 -0.533247 0.525409 0.0228865 0.0664948 1.00000e-08 0.908353
##  17:     5213.0821: 0.0242437 -0.493604 0.488958 0.0244530 0.0667843 1.00000e-08 0.908070
##  18:     5212.9776: 0.0244681 -0.452790 0.455340 0.0236788 0.0634978 1.00000e-08 0.910870
##  19:     5212.7065: 0.0247227 -0.417754 0.416231 0.0253049 0.0661872 1.00000e-08 0.907624
##  20:     5212.7040: 0.0247498 -0.415340 0.413411 0.0248911 0.0660608 1.00000e-08 0.907101
##  21:     5212.6468: 0.0247761 -0.414433 0.412273 0.0251086 0.0662200 1.00000e-08 0.907319
##  22:     5212.6220: 0.0248350 -0.413261 0.409971 0.0246027 0.0661375 1.00000e-08 0.907732
##  23:     5212.5862: 0.0249696 -0.410638 0.406755 0.0247094 0.0661152 1.00000e-08 0.908051
##  24:     5212.3563: 0.0270722 -0.391514 0.382989 0.0236193 0.0642204 1.00000e-08 0.910741
##  25:     5211.9132: 0.0357740 -0.360360 0.350679 0.0257733 0.0678383 1.00000e-08 0.904758
##  26:     5211.3800: 0.0444757 -0.390622 0.384461 0.0246234 0.0660680 1.00000e-08 0.907960
##  27:     5211.2321: 0.0531993 -0.414601 0.406828 0.0237811 0.0655741 1.00000e-08 0.908970
##  28:     5211.2272: 0.0562399 -0.405560 0.398092 0.0240485 0.0655162 1.00000e-08 0.909800
##  29:     5211.1854: 0.0567350 -0.391813 0.386042 0.0238080 0.0649586 1.00000e-08 0.909922
##  30:     5211.1769: 0.0563419 -0.409388 0.402228 0.0238518 0.0653094 1.00000e-08 0.909474
##  31:     5211.1741: 0.0563754 -0.406971 0.400241 0.0238800 0.0652444 1.00000e-08 0.909625
##  32:     5211.1741: 0.0564272 -0.406613 0.399830 0.0238624 0.0652449 1.00000e-08 0.909638
##  33:     5211.1741: 0.0564163 -0.406699 0.399924 0.0238655 0.0652397 1.00000e-08 0.909638
##  34:     5211.1741: 0.0564160 -0.406697 0.399922 0.0238652 0.0652409 1.00000e-08 0.909637
## 
## Final Estimate of the Negative LLH:
##  LLH:  -9484.041    norm LLH:  -2.420633 
##            mu           ar1           ma1         omega        alpha1 
##  0.0013258580 -0.4066972343  0.3999221765  0.0000131812  0.0652409347 
##        alpha2         beta1 
##  0.0000000100  0.9096373842 
## 
## R-optimhess Difference Approximated Hessian Matrix:
##                   mu           ar1          ma1         omega
## mu      -5022313.258   -3106.10706    1467.9016 -6.494451e+07
## ar1        -3106.107   -4104.04611   -4054.6988 -3.299989e+05
## ma1         1467.902   -4054.69876   -4078.3208 -2.653953e+05
## omega  -64944511.281 -329998.93788 -265395.2890 -1.541597e+12
## alpha1     -2116.077     237.44550     248.6985 -4.755036e+08
## alpha2     -4671.943      24.66506      31.3775 -4.802673e+08
## beta1     -24822.160    -464.31772    -437.5701 -6.102480e+08
##               alpha1        alpha2         beta1
## mu     -2.116077e+03 -4.671943e+03 -2.482216e+04
## ar1     2.374455e+02  2.466506e+01 -4.643177e+02
## ma1     2.486985e+02  3.137750e+01 -4.375701e+02
## omega  -4.755036e+08 -4.802673e+08 -6.102480e+08
## alpha1 -2.037639e+05 -2.026692e+05 -2.227293e+05
## alpha2 -2.026692e+05 -2.064801e+05 -2.268346e+05
## beta1  -2.227293e+05 -2.268346e+05 -2.704929e+05
## attr(,"time")
## Time difference of 0.1428339 secs
## 
## --- END OF TRACE ---
## 
## 
## Time to Estimate Parameters:
##  Time difference of 0.5629599 secs
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~arma(1, 1) + garch(2, 1), data = d.series.name, 
##     include.mean = TRUE) 
## 
## Mean and Variance Equation:
##  data ~ arma(1, 1) + garch(2, 1)
## <environment: 0x7fd99b30c5f0>
##  [data = d.series.name]
## 
## Conditional Distribution:
##  norm 
## 
## Coefficient(s):
##          mu          ar1          ma1        omega       alpha1  
##  1.3259e-03  -4.0670e-01   3.9992e-01   1.3181e-05   6.5241e-02  
##      alpha2        beta1  
##  1.0000e-08   9.0964e-01  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##          Estimate  Std. Error  t value Pr(>|t|)    
## mu      1.326e-03   4.606e-04    2.879 0.003992 ** 
## ar1    -4.067e-01   1.207e-01   -3.370 0.000751 ***
## ma1     3.999e-01   1.210e-01    3.304 0.000953 ***
## omega   1.318e-05   3.156e-06    4.176 2.96e-05 ***
## alpha1  6.524e-02   1.460e-02    4.467 7.92e-06 ***
## alpha2  1.000e-08   1.821e-02    0.000 1.000000    
## beta1   9.096e-01   1.407e-02   64.664  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  9484.041    normalized:  2.420633 
## 
## Description:
##  Tue Nov 17 21:00:07 2015 by user:  
## 
## 
## Standardised Residuals Tests:
##                                 Statistic p-Value  
##  Jarque-Bera Test   R    Chi^2  971.1246  0        
##  Shapiro-Wilk Test  R    W      0.9809592 0        
##  Ljung-Box Test     R    Q(10)  18.7516   0.0435336
##  Ljung-Box Test     R    Q(15)  22.05512  0.1063667
##  Ljung-Box Test     R    Q(20)  26.09027  0.1628511
##  Ljung-Box Test     R^2  Q(10)  8.514667  0.5786967
##  Ljung-Box Test     R^2  Q(15)  11.93925  0.6836212
##  Ljung-Box Test     R^2  Q(20)  13.84031  0.8384995
##  LM Arch Test       R    TR^2   10.76726  0.5489633
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -4.837693 -4.826485 -4.837699 -4.833716

# BBAS3.SA
stock.name <- "BBAS3.SA"
stock.description <- "Banco do Brasil S.A."
# Call your function and pass x and y to the function
run <- generateAnalysis(stock.name,stock.description)
## time series starts 2000-01-03
## 'zoo' series from 2000-01-03 to 2015-11-16
##   Data: num [1:4097, 1] 1.89 1.8 1.82 1.85 1.8 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr "AdjClose"
##   Index:  Date[1:4097], format: "2000-01-03" "2000-01-04" "2000-01-05" "2000-01-06" ...

## 'zoo' series from 2000-01-03 to 2015-09-30
##   Data: num [1:4064] 1.89 1.8 1.82 1.85 1.8 ...
##   Index:  Date[1:4064], format: "2000-01-03" "2000-01-04" "2000-01-05" "2000-01-06" ...

## Warning in adf.test(d.series.name): p-value smaller than printed p-value

## Warning in sqrt(diag(fit$var.coef)): NaNs produced

## 
## Title:
##  ARIMA Modelling 
## 
## Call:
##  armaFit(formula = ~arma(1, 3), data = d.series.name)
## 
## Model:
##  ARIMA(1,0,3) with method: CSS-ML
## 
## Coefficient(s):
##        ar1         ma1         ma2         ma3   intercept  
## -0.0060659  -0.0058871  -0.0409504  -0.0208741   0.0005117  
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.1642276 -0.0152146 -0.0004861  0.0143946  0.2561532 
## 
## Moments: 
## Skewness Kurtosis 
##   0.4049   5.0957 
## 
## Coefficient(s):
##             Estimate  Std. Error  t value Pr(>|t|)    
## ar1       -0.0060659          NA       NA       NA    
## ma1       -0.0058871          NA       NA       NA    
## ma2       -0.0409504   0.0112869   -3.628 0.000285 ***
## ma3       -0.0208741          NA       NA       NA    
## intercept  0.0005117   0.0003929    1.302 0.192873    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## sigma^2 estimated as: 0.0007293
## log likelihood:       8909.2
## AIC Criterion:        -17806.39

## 
## Description:
##  Tue Nov 17 21:00:13 2015 by user:

## 
## Series Initialization:
##  ARMA Model:                arma
##  Formula Mean:              ~ arma(1, 1)
##  GARCH Model:               garch
##  Formula Variance:          ~ garch(2, 1)
##  ARMA Order:                1 1
##  Max ARMA Order:            1
##  GARCH Order:               2 1
##  Max GARCH Order:           2
##  Maximum Order:             2
##  Conditional Dist:          norm
##  h.start:                   3
##  llh.start:                 1
##  Length of Series:          4063
##  Recursion Init:            mci
##  Series Scale:              0.02703797
## 
## Parameter Initialization:
##  Initial Parameters:          $params
##  Limits of Transformations:   $U, $V
##  Which Parameters are Fixed?  $includes
##  Parameter Matrix:
##                      U           V      params includes
##     mu     -0.18874649   0.1887465  0.01895864     TRUE
##     ar1    -0.99999999   1.0000000  0.80993389     TRUE
##     ma1    -0.99999999   1.0000000 -0.83800546     TRUE
##     omega   0.00000100 100.0000000  0.10000000     TRUE
##     alpha1  0.00000001   1.0000000  0.05000000     TRUE
##     alpha2  0.00000001   1.0000000  0.05000000     TRUE
##     gamma1 -0.99999999   1.0000000  0.10000000    FALSE
##     gamma2 -0.99999999   1.0000000  0.10000000    FALSE
##     beta1   0.00000001   1.0000000  0.80000000     TRUE
##     delta   0.00000000   2.0000000  2.00000000    FALSE
##     skew    0.10000000  10.0000000  1.00000000    FALSE
##     shape   1.00000000  10.0000000  4.00000000    FALSE
##  Index List of Parameters to be Optimized:
##     mu    ar1    ma1  omega alpha1 alpha2  beta1 
##      1      2      3      4      5      6      9 
##  Persistence:                  0.9 
## 
## 
## --- START OF TRACE ---
## Selected Algorithm: nlminb 
## 
## R coded nlminb Solver: 
## 
##   0:     5457.6846: 0.0189586 0.809934 -0.838005 0.100000 0.0500000 0.0500000 0.800000
##   1:     5448.6230: 0.0189512 0.809839 -0.835474 0.0898785 0.0507273 0.0487415 0.794442
##   2:     5442.4340: 0.0189415 0.809405 -0.832515 0.0880046 0.0597897 0.0549649 0.797348
##   3:     5436.5470: 0.0189152 0.807386 -0.825576 0.0676436 0.0673200 0.0555947 0.790848
##   4:     5426.8181: 0.0188584 0.798936 -0.815591 0.0652979 0.0841753 0.0589046 0.800195
##   5:     5420.4308: 0.0187833 0.784786 -0.806455 0.0579613 0.0894704 0.0462541 0.805359
##   6:     5416.9210: 0.0187173 0.779379 -0.792347 0.0567631 0.0924189 0.0336990 0.818002
##   7:     5411.1121: 0.0186156 0.754793 -0.791385 0.0405858 0.0982305 0.0128491 0.848130
##   8:     5409.7015: 0.0185896 0.760389 -0.777792 0.0405372 0.101550 0.00919626 0.853267
##   9:     5408.5524: 0.0185886 0.760198 -0.777717 0.0389537 0.100721 0.00808408 0.852234
##  10:     5406.3344: 0.0184971 0.750615 -0.767828 0.0252059 0.101208 1.00000e-08 0.877604
##  11:     5406.1597: 0.0184957 0.750340 -0.767733 0.0251621 0.100258 1.00000e-08 0.876989
##  12:     5406.0284: 0.0184944 0.750077 -0.767636 0.0262417 0.100055 1.00000e-08 0.877275
##  13:     5405.7455: 0.0184839 0.748556 -0.766630 0.0259043 0.0987335 1.00000e-08 0.877285
##  14:     5405.3421: 0.0184608 0.745350 -0.764335 0.0266123 0.0972636 1.00000e-08 0.878788
##  15:     5404.7099: 0.0184101 0.739150 -0.758997 0.0258351 0.0941645 1.00000e-08 0.880651
##  16:     5404.1564: 0.0183482 0.733554 -0.752326 0.0268860 0.0939016 1.00000e-08 0.880971
##  17:     5403.7277: 0.0182858 0.726611 -0.748725 0.0277345 0.0956041 1.00000e-08 0.877491
##  18:     5403.4097: 0.0182166 0.724362 -0.740940 0.0274321 0.0935213 1.00000e-08 0.879576
##  19:     5403.3920: 0.0182159 0.724136 -0.740967 0.0276334 0.0935914 1.00000e-08 0.879720
##  20:     5403.3755: 0.0182150 0.723892 -0.740991 0.0274767 0.0934541 1.00000e-08 0.879603
##  21:     5403.3421: 0.0182104 0.723420 -0.740836 0.0276112 0.0933396 1.00000e-08 0.879976
##  22:     5402.7108: 0.0179946 0.710441 -0.730985 0.0243641 0.0841437 1.00000e-08 0.890889
##  23:     5402.0966: 0.0177380 0.696798 -0.718082 0.0274737 0.0893269 1.00000e-08 0.884856
##  24:     5401.3807: 0.0174768 0.683348 -0.705267 0.0287826 0.0931196 1.00000e-08 0.877261
##  25:     5400.9802: 0.0171787 0.670688 -0.693150 0.0314270 0.0974753 1.00000e-08 0.871977
##  26:     5400.6633: 0.0167778 0.661792 -0.684387 0.0299056 0.0983931 1.00000e-08 0.872232
##  27:     5400.2704: 0.0167978 0.647076 -0.669057 0.0259758 0.0925262 1.00000e-08 0.882616
##  28:     5400.0151: 0.0169630 0.630712 -0.652916 0.0275694 0.0909190 1.00000e-08 0.882089
##  29:     5399.9636: 0.0173526 0.621038 -0.643404 0.0271464 0.0908668 1.00000e-08 0.881716
##  30:     5399.8658: 0.0177522 0.611952 -0.634495 0.0274228 0.0913094 1.00000e-08 0.881591
##  31:     5399.3538: 0.0213110 0.500313 -0.523807 0.0279076 0.0940967 1.00000e-08 0.878563
##  32:     5399.2251: 0.0191978 0.466558 -0.483766 0.0268284 0.0887763 1.00000e-08 0.884849
##  33:     5399.1103: 0.0234932 0.401391 -0.418621 0.0261198 0.0878483 1.00000e-08 0.886409
##  34:     5399.0336: 0.0262712 0.337204 -0.352604 0.0267305 0.0921582 1.00000e-08 0.881854
##  35:     5398.9838: 0.0285025 0.278770 -0.292322 0.0266300 0.0913075 1.00000e-08 0.882708
##  36:     5398.8630: 0.0364577 0.0724663 -0.0783251 0.0263701 0.0901451 1.00000e-08 0.884069
##  37:     5398.8298: 0.0393060 -0.000498041 -0.00276615 0.0262887 0.0900117 1.00000e-08 0.884279
##  38:     5398.8110: 0.0421407 -0.0743688 0.0733277 0.0262496 0.0900638 1.00000e-08 0.884293
##  39:     5398.8087: 0.0428406 -0.0965928 0.0956394 0.0263022 0.0903471 1.00000e-08 0.883994
##  40:     5398.8081: 0.0425199 -0.0922147 0.0908072 0.0263344 0.0904818 1.00000e-08 0.883838
##  41:     5398.8080: 0.0423845 -0.0916946 0.0902489 0.0263327 0.0904807 1.00000e-08 0.883839
##  42:     5398.8078: 0.0421403 -0.0913682 0.0899797 0.0263270 0.0904454 1.00000e-08 0.883875
##  43:     5398.8078: 0.0421355 -0.0915641 0.0902144 0.0263274 0.0904372 1.00000e-08 0.883883
##  44:     5398.8078: 0.0421385 -0.0916017 0.0902608 0.0263276 0.0904362 1.00000e-08 0.883884
## 
## Final Estimate of the Negative LLH:
##  LLH:  -9270.707    norm LLH:  -2.281739 
##            mu           ar1           ma1         omega        alpha1 
##  1.139340e-03 -9.160171e-02  9.026077e-02  1.924684e-05  9.043619e-02 
##        alpha2         beta1 
##  1.000000e-08  8.838836e-01 
## 
## R-optimhess Difference Approximated Hessian Matrix:
##                   mu           ar1           ma1         omega
## mu      -6675891.883 -5.271891e+03    1636.76966 -6.540062e+07
## ar1        -5271.891 -3.621288e+03   -3538.63805 -6.971005e+05
## ma1         1636.770 -3.538638e+03   -3470.56094 -6.281335e+05
## omega  -65400616.394 -6.971005e+05 -628133.48710 -6.132797e+11
## alpha1     -3140.197  1.396146e+02     143.55431 -2.265059e+08
## alpha2     -3997.903  1.778744e+02     182.47165 -2.270998e+08
## beta1     -19419.766 -7.795566e+00      13.27731 -3.055775e+08
##               alpha1        alpha2         beta1
## mu     -3.140197e+03 -3.997903e+03 -1.941977e+04
## ar1     1.396146e+02  1.778744e+02 -7.795566e+00
## ma1     1.435543e+02  1.824716e+02  1.327731e+01
## omega  -2.265059e+08 -2.270998e+08 -3.055775e+08
## alpha1 -1.236241e+05 -1.219247e+05 -1.385001e+05
## alpha2 -1.219247e+05 -1.236789e+05 -1.397765e+05
## beta1  -1.385001e+05 -1.397765e+05 -1.715036e+05
## attr(,"time")
## Time difference of 0.1511841 secs
## 
## --- END OF TRACE ---
## 
## 
## Time to Estimate Parameters:
##  Time difference of 0.6650529 secs
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~arma(1, 1) + garch(2, 1), data = d.series.name, 
##     include.mean = TRUE) 
## 
## Mean and Variance Equation:
##  data ~ arma(1, 1) + garch(2, 1)
## <environment: 0x7fd9a59ec6a8>
##  [data = d.series.name]
## 
## Conditional Distribution:
##  norm 
## 
## Coefficient(s):
##          mu          ar1          ma1        omega       alpha1  
##  1.1393e-03  -9.1602e-02   9.0261e-02   1.9247e-05   9.0436e-02  
##      alpha2        beta1  
##  1.0000e-08   8.8388e-01  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##          Estimate  Std. Error  t value Pr(>|t|)    
## mu      1.139e-03   5.746e-04    1.983   0.0474 *  
## ar1    -9.160e-02   4.077e-01   -0.225   0.8222    
## ma1     9.026e-02   4.162e-01    0.217   0.8283    
## omega   1.925e-05   7.174e-06    2.683   0.0073 ** 
## alpha1  9.044e-02   1.717e-02    5.266 1.39e-07 ***
## alpha2  1.000e-08   2.491e-02    0.000   1.0000    
## beta1   8.839e-01   2.732e-02   32.359  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  9270.707    normalized:  2.281739 
## 
## Description:
##  Tue Nov 17 21:00:15 2015 by user:  
## 
## 
## Standardised Residuals Tests:
##                                 Statistic p-Value   
##  Jarque-Bera Test   R    Chi^2  453.9555  0         
##  Shapiro-Wilk Test  R    W      0.9879194 0         
##  Ljung-Box Test     R    Q(10)  6.360203  0.7841474 
##  Ljung-Box Test     R    Q(15)  9.01403   0.8767827 
##  Ljung-Box Test     R    Q(20)  11.1717   0.9416477 
##  Ljung-Box Test     R^2  Q(10)  22.02578  0.01497378
##  Ljung-Box Test     R^2  Q(15)  27.53481  0.02466916
##  Ljung-Box Test     R^2  Q(20)  33.57486  0.02914862
##  LM Arch Test       R    TR^2   21.82948  0.03947601
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -4.560033 -4.549162 -4.560039 -4.556182

# KROT3.SA
stock.name <- "KROT3.SA"
stock.description <- "Kroton Educacional S.A."
# Call your function and pass x and y to the function
run <- generateAnalysis(stock.name,stock.description)
## time series starts 2012-03-14
## 'zoo' series from 2012-03-14 to 2015-11-16
##   Data: num [1:957, 1] 2.21 2.21 2.21 2.21 2.21 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr "AdjClose"
##   Index:  Date[1:957], format: "2012-03-14" "2012-03-15" "2012-03-16" "2012-03-19" ...

## 'zoo' series from 2012-03-14 to 2015-09-30
##   Data: num [1:924] 2.21 2.21 2.21 2.21 2.21 ...
##   Index:  Date[1:924], format: "2012-03-14" "2012-03-15" "2012-03-16" "2012-03-19" ...

## Warning in adf.test(d.series.name): p-value smaller than printed p-value

## Warning in lsfit(log10(M), log10(RS), wt): 29 missing values deleted

## 
## Title:
##  ARIMA Modelling 
## 
## Call:
##  armaFit(formula = ~arma(1, 3), data = d.series.name)
## 
## Model:
##  ARIMA(1,0,3) with method: CSS-ML
## 
## Coefficient(s):
##       ar1        ma1        ma2        ma3  intercept  
##  0.426797  -0.560552   0.053052  -0.238926   0.001384  
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -1.391973 -0.011893 -0.001244  0.015092  1.275535 
## 
## Moments: 
## Skewness Kurtosis 
##   -1.295  120.049 
## 
## Coefficient(s):
##            Estimate  Std. Error  t value Pr(>|t|)    
## ar1        0.426797    0.076118    5.607 2.06e-08 ***
## ma1       -0.560552    0.074747   -7.499 6.42e-14 ***
## ma2        0.053052    0.043406    1.222    0.222    
## ma3       -0.238926    0.031674   -7.543 4.57e-14 ***
## intercept  0.001384    0.001440    0.961    0.336    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## sigma^2 estimated as: 0.00969
## log likelihood:       829.97
## AIC Criterion:        -1647.94

## 
## Description:
##  Tue Nov 17 21:00:17 2015 by user:

## Warning in lsfit(log10(M), log10(RS), wt): 29 missing values deleted

## 
## Series Initialization:
##  ARMA Model:                arma
##  Formula Mean:              ~ arma(1, 1)
##  GARCH Model:               garch
##  Formula Variance:          ~ garch(2, 1)
##  ARMA Order:                1 1
##  Max ARMA Order:            1
##  GARCH Order:               2 1
##  Max GARCH Order:           2
##  Maximum Order:             2
##  Conditional Dist:          norm
##  h.start:                   3
##  llh.start:                 1
##  Length of Series:          923
##  Recursion Init:            mci
##  Series Scale:              0.1033657
## 
## Parameter Initialization:
##  Initial Parameters:          $params
##  Limits of Transformations:   $U, $V
##  Which Parameters are Fixed?  $includes
##  Parameter Matrix:
##                      U           V      params includes
##     mu     -0.13042069   0.1304207  0.01305813     TRUE
##     ar1    -0.99999999   1.0000000 -0.52596396     TRUE
##     ma1    -0.99999999   1.0000000  0.45626181     TRUE
##     omega   0.00000100 100.0000000  0.10000000     TRUE
##     alpha1  0.00000001   1.0000000  0.05000000     TRUE
##     alpha2  0.00000001   1.0000000  0.05000000     TRUE
##     gamma1 -0.99999999   1.0000000  0.10000000    FALSE
##     gamma2 -0.99999999   1.0000000  0.10000000    FALSE
##     beta1   0.00000001   1.0000000  0.80000000     TRUE
##     delta   0.00000000   2.0000000  2.00000000    FALSE
##     skew    0.10000000  10.0000000  1.00000000    FALSE
##     shape   1.00000000  10.0000000  4.00000000    FALSE
##  Index List of Parameters to be Optimized:
##     mu    ar1    ma1  omega alpha1 alpha2  beta1 
##      1      2      3      4      5      6      9 
##  Persistence:                  0.9 
## 
## 
## --- START OF TRACE ---
## Selected Algorithm: nlminb 
## 
## R coded nlminb Solver: 
## 
##   0:     967.58942: 0.0130581 -0.525964 0.456262 0.100000 0.0500000 0.0500000 0.800000
##   1:     946.80898: 0.0130581 -0.526246 0.455994 0.0849877 0.0504835 0.0491423 0.790264
##   2:     941.35280: 0.0130579 -0.526773 0.455496 0.0699198 0.0525607 0.0485962 0.780825
##   3:     938.20876: 0.0130572 -0.528770 0.453608 0.0805589 0.0637244 0.0496474 0.772176
##   4:     936.01889: 0.0130559 -0.531357 0.451178 0.0787447 0.0735573 0.0495962 0.757730
##   5:     933.89311: 0.0130500 -0.539192 0.443934 0.0959114 0.0833502 0.0517521 0.729877
##   6:     932.39394: 0.0130443 -0.545643 0.438012 0.0908191 0.107386 0.0757073 0.724335
##   7:     932.25930: 0.0130123 -0.553081 0.431147 0.0989278 0.0933489 0.0750350 0.694113
##   8:     931.78839: 0.0130120 -0.553271 0.430965 0.103134 0.0953226 0.0765080 0.696866
##   9:     931.60029: 0.0130114 -0.553655 0.430599 0.0991742 0.0985884 0.0786114 0.697459
##  10:     931.41811: 0.0129993 -0.556044 0.428190 0.101352 0.104982 0.0720578 0.702428
##  11:     931.25579: 0.0129763 -0.557703 0.426417 0.0985900 0.112384 0.0646962 0.702315
##  12:     931.17804: 0.0128827 -0.548232 0.435006 0.103903 0.124977 0.0654636 0.692311
##  13:     931.01319: 0.0126245 -0.573829 0.409419 0.0999748 0.136144 0.0549268 0.699869
##  14:     931.00259: 0.0126239 -0.573381 0.409825 0.0993139 0.136706 0.0553676 0.699628
##  15:     930.99164: 0.0126203 -0.572839 0.410271 0.0999484 0.137192 0.0554033 0.700031
##  16:     930.97702: 0.0126075 -0.571589 0.411215 0.0991066 0.138019 0.0547034 0.700456
##  17:     930.96119: 0.0125712 -0.569293 0.412759 0.0993224 0.139346 0.0531641 0.702003
##  18:     930.93498: 0.0124562 -0.567325 0.413003 0.0989396 0.138627 0.0551729 0.700851
##  19:     930.90891: 0.0122255 -0.566167 0.411178 0.100877 0.137685 0.0590722 0.697159
##  20:     930.87405: 0.0120102 -0.562354 0.412211 0.0997537 0.142229 0.0528290 0.698606
##  21:     930.85152: 0.0117723 -0.559090 0.414083 0.100088 0.143340 0.0528754 0.700270
##  22:     930.83165: 0.0115337 -0.557912 0.414836 0.0990335 0.141898 0.0561553 0.699591
##  23:     930.75889: 0.00971934 -0.551668 0.409794 0.0988277 0.151849 0.0433092 0.699115
##  24:     930.27939: -0.00114068 -0.516561 0.379595 0.103142 0.163531 0.0522702 0.688221
##  25:     930.01328: -0.0119426 -0.435956 0.322737 0.100179 0.166044 0.0446284 0.698160
##  26:     929.73136: -0.0226798 -0.354896 0.216785 0.101193 0.156178 0.0578991 0.694307
##  27:     929.60081: -0.0299643 -0.410601 0.275530 0.102152 0.132696 0.0777366 0.690777
##  28:     929.55580: -0.0329053 -0.477743 0.335559 0.101214 0.132565 0.0781253 0.692050
##  29:     929.55554: -0.0348876 -0.436081 0.284208 0.100764 0.130674 0.0805701 0.692226
##  30:     929.55057: -0.0341590 -0.465515 0.317678 0.100888 0.131164 0.0797313 0.692133
##  31:     929.55056: -0.0341556 -0.464813 0.317285 0.100891 0.131355 0.0795513 0.692152
##  32:     929.55055: -0.0341711 -0.465080 0.317505 0.100891 0.131290 0.0795890 0.692155
##  33:     929.55055: -0.0341724 -0.465094 0.317513 0.100890 0.131296 0.0795832 0.692155
## 
## Final Estimate of the Negative LLH:
##  LLH:  -1165.182    norm LLH:  -1.262385 
##           mu          ar1          ma1        omega       alpha1 
## -0.003532254 -0.465093595  0.317512574  0.001077959  0.131295992 
##       alpha2        beta1 
##  0.079583204  0.692155043 
## 
## R-optimhess Difference Approximated Hessian Matrix:
##                   mu        ar1          ma1         omega       alpha1
## mu     -128480.59912  197.32587   -99.984334  6.906563e+05   -575.83877
## ar1        197.32587 -217.76756  -201.662115  6.182968e+03     55.48211
## ma1        -99.98433 -201.66211  -194.416743  1.006964e+04     42.66468
## omega   690656.27134 6182.96839 10069.639030 -3.158162e+08 -97893.80662
## alpha1    -575.83877   55.48211    42.664676 -9.789381e+04  -1099.55414
## alpha2   -2774.72114   14.70127    -7.695865 -8.393257e+04  -1090.21732
## beta1     -228.62597   88.37801    88.268715 -1.154244e+06  -1584.54527
##               alpha2         beta1
## mu      -2774.721135 -2.286260e+02
## ar1        14.701266  8.837801e+01
## ma1        -7.695865  8.826871e+01
## omega  -83932.570964 -1.154244e+06
## alpha1  -1090.217315 -1.584545e+03
## alpha2  -1560.334134 -2.090775e+03
## beta1   -2090.775041 -7.710301e+03
## attr(,"time")
## Time difference of 0.04776287 secs
## 
## --- END OF TRACE ---
## 
## 
## Time to Estimate Parameters:
##  Time difference of 0.1388369 secs
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~arma(1, 1) + garch(2, 1), data = d.series.name, 
##     include.mean = TRUE) 
## 
## Mean and Variance Equation:
##  data ~ arma(1, 1) + garch(2, 1)
## <environment: 0x7fd99d7b0000>
##  [data = d.series.name]
## 
## Conditional Distribution:
##  norm 
## 
## Coefficient(s):
##         mu         ar1         ma1       omega      alpha1      alpha2  
## -0.0035323  -0.4650936   0.3175126   0.0010780   0.1312960   0.0795832  
##      beta1  
##  0.6921550  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##          Estimate  Std. Error  t value Pr(>|t|)    
## mu     -0.0035323   0.0030173   -1.171   0.2417    
## ar1    -0.4650936   0.3648070   -1.275   0.2023    
## ma1     0.3175126   0.3879403    0.818   0.4131    
## omega   0.0010780   0.0001064   10.134   <2e-16 ***
## alpha1  0.1312960   0.0569969    2.304   0.0212 *  
## alpha2  0.0795832   0.0594417    1.339   0.1806    
## beta1   0.6921550   0.0270258   25.611   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  1165.182    normalized:  1.262385 
## 
## Description:
##  Tue Nov 17 21:00:18 2015 by user:  
## 
## 
## Standardised Residuals Tests:
##                                 Statistic p-Value     
##  Jarque-Bera Test   R    Chi^2  3935116   0           
##  Shapiro-Wilk Test  R    W      0.3097579 0           
##  Ljung-Box Test     R    Q(10)  27.76416  0.001968995 
##  Ljung-Box Test     R    Q(15)  39.54696  0.0005306483
##  Ljung-Box Test     R    Q(20)  40.11346  0.004832976 
##  Ljung-Box Test     R^2  Q(10)  5.702808  0.8395835   
##  Ljung-Box Test     R^2  Q(15)  6.09349   0.9781342   
##  Ljung-Box Test     R^2  Q(20)  6.132036  0.9987071   
##  LM Arch Test       R    TR^2   5.873323  0.9223325   
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -2.509603 -2.472990 -2.509717 -2.495634

# VALE5.SA
stock.name <- "VALE5.SA"
stock.description <- "Vale S.A."
# Call your function and pass x and y to the function
run <- generateAnalysis(stock.name,stock.description)
## time series starts 2003-01-01
## 'zoo' series from 2003-01-01 to 2015-11-16
##   Data: num [1:3191, 1] 6.07 6.07 6 5.84 5.71 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr "AdjClose"
##   Index:  Date[1:3191], format: "2003-01-01" "2003-01-02" "2003-01-03" "2003-01-06" ...

## 'zoo' series from 2003-01-01 to 2015-09-30
##   Data: num [1:3158] 6.07 6.07 6 5.84 5.71 ...
##   Index:  Date[1:3158], format: "2003-01-01" "2003-01-02" "2003-01-03" "2003-01-06" ...

## Warning in adf.test(d.series.name): p-value smaller than printed p-value

## 
## Title:
##  ARIMA Modelling 
## 
## Call:
##  armaFit(formula = ~arma(1, 3), data = d.series.name)
## 
## Model:
##  ARIMA(1,0,3) with method: CSS-ML
## 
## Coefficient(s):
##        ar1         ma1         ma2         ma3   intercept  
## -0.1147017   0.1352835  -0.0466870  -0.0628895   0.0002432  
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.1591899 -0.0125681  0.0002449  0.0123261  0.1234791 
## 
## Moments: 
## Skewness Kurtosis 
##  -0.0741   3.2827 
## 
## Coefficient(s):
##             Estimate  Std. Error  t value Pr(>|t|)   
## ar1       -0.1147017   0.2806508   -0.409  0.68276   
## ma1        0.1352835   0.2799768    0.483  0.62896   
## ma2       -0.0466870   0.0185914   -2.511  0.01203 * 
## ma3       -0.0628895   0.0207959   -3.024  0.00249 **
## intercept  0.0002432   0.0003799    0.640  0.52203   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## sigma^2 estimated as: 0.0005368
## log likelihood:       7406.32
## AIC Criterion:        -14800.64

## 
## Description:
##  Tue Nov 17 21:00:21 2015 by user:

## 
## Series Initialization:
##  ARMA Model:                arma
##  Formula Mean:              ~ arma(1, 1)
##  GARCH Model:               garch
##  Formula Variance:          ~ garch(2, 1)
##  ARMA Order:                1 1
##  Max ARMA Order:            1
##  GARCH Order:               2 1
##  Max GARCH Order:           2
##  Maximum Order:             2
##  Conditional Dist:          norm
##  h.start:                   3
##  llh.start:                 1
##  Length of Series:          3157
##  Recursion Init:            mci
##  Series Scale:              0.02324454
## 
## Parameter Initialization:
##  Initial Parameters:          $params
##  Limits of Transformations:   $U, $V
##  Which Parameters are Fixed?  $includes
##  Parameter Matrix:
##                      U           V      params includes
##     mu     -0.10373679   0.1037368  0.01037722     TRUE
##     ar1    -0.99999999   1.0000000 -0.29796748     TRUE
##     ma1    -0.99999999   1.0000000  0.32712119     TRUE
##     omega   0.00000100 100.0000000  0.10000000     TRUE
##     alpha1  0.00000001   1.0000000  0.05000000     TRUE
##     alpha2  0.00000001   1.0000000  0.05000000     TRUE
##     gamma1 -0.99999999   1.0000000  0.10000000    FALSE
##     gamma2 -0.99999999   1.0000000  0.10000000    FALSE
##     beta1   0.00000001   1.0000000  0.80000000     TRUE
##     delta   0.00000000   2.0000000  2.00000000    FALSE
##     skew    0.10000000  10.0000000  1.00000000    FALSE
##     shape   1.00000000  10.0000000  4.00000000    FALSE
##  Index List of Parameters to be Optimized:
##     mu    ar1    ma1  omega alpha1 alpha2  beta1 
##      1      2      3      4      5      6      9 
##  Persistence:                  0.9 
## 
## 
## --- START OF TRACE ---
## Selected Algorithm: nlminb 
## 
## R coded nlminb Solver: 
## 
##   0:     4220.5083: 0.0103772 -0.297967 0.327121 0.100000 0.0500000 0.0500000 0.800000
##   1:     4216.4468: 0.0103774 -0.296902 0.328160 0.0816230 0.0481218 0.0498433 0.791563
##   2:     4202.4737: 0.0103776 -0.295404 0.329616 0.0777685 0.0600405 0.0645020 0.797769
##   3:     4198.9154: 0.0103780 -0.292750 0.332172 0.0587052 0.0616100 0.0704353 0.797734
##   4:     4194.2747: 0.0103790 -0.287891 0.336765 0.0546845 0.0600077 0.0768558 0.815341
##   5:     4190.1470: 0.0103804 -0.284722 0.339464 0.0456379 0.0492084 0.0747525 0.829284
##   6:     4182.8614: 0.0103854 -0.293368 0.328157 0.0237297 0.0227754 0.0634317 0.889690
##   7:     4182.8353: 0.0103855 -0.293172 0.328344 0.0242027 0.0229698 0.0634197 0.890115
##   8:     4182.7486: 0.0103855 -0.292912 0.328582 0.0238916 0.0227839 0.0629200 0.890215
##   9:     4182.6518: 0.0103857 -0.292277 0.329168 0.0241073 0.0229477 0.0622721 0.891122
##  10:     4182.4173: 0.0103860 -0.291210 0.330102 0.0232492 0.0231238 0.0604766 0.892623
##  11:     4181.8799: 0.0103880 -0.288251 0.332266 0.0205962 0.0275671 0.0531453 0.899710
##  12:     4181.7725: 0.0103902 -0.287643 0.331915 0.0206318 0.0271576 0.0478972 0.902241
##  13:     4181.6885: 0.0103916 -0.287509 0.331421 0.0214289 0.0281363 0.0463689 0.904001
##  14:     4181.5292: 0.0103931 -0.288049 0.330189 0.0206087 0.0297673 0.0449076 0.903903
##  15:     4181.5001: 0.0103932 -0.287721 0.330471 0.0201571 0.0303208 0.0450884 0.904273
##  16:     4181.4903: 0.0103942 -0.287342 0.330390 0.0197856 0.0303187 0.0443849 0.904545
##  17:     4181.4478: 0.0103953 -0.287039 0.330247 0.0198494 0.0306317 0.0438646 0.905156
##  18:     4181.3822: 0.0104005 -0.285592 0.329373 0.0192441 0.0316866 0.0409189 0.907264
##  19:     4181.3710: 0.0104263 -0.279882 0.323830 0.0193311 0.0323208 0.0402627 0.908013
##  20:     4181.3098: 0.0104526 -0.273730 0.318727 0.0190792 0.0318363 0.0407459 0.907759
##  21:     4181.2973: 0.0104687 -0.271159 0.314781 0.0187759 0.0339347 0.0392624 0.907976
##  22:     4181.2557: 0.0105059 -0.262338 0.309281 0.0185062 0.0324165 0.0406556 0.907948
##  23:     4181.1332: 0.0107154 -0.225419 0.269950 0.0185378 0.0351948 0.0352990 0.909883
##  24:     4181.1144: 0.0107154 -0.225398 0.269969 0.0186356 0.0353079 0.0354033 0.909986
##  25:     4181.1067: 0.0107155 -0.225321 0.270037 0.0184745 0.0353859 0.0354492 0.909975
##  26:     4181.1030: 0.0107170 -0.225004 0.269834 0.0184924 0.0354696 0.0355134 0.910044
##  27:     4181.0977: 0.0107201 -0.224394 0.269340 0.0184091 0.0354496 0.0354811 0.910031
##  28:     4181.0908: 0.0107263 -0.223166 0.268353 0.0183983 0.0355081 0.0355120 0.910119
##  29:     4180.9833: 0.0109980 -0.172220 0.223144 0.0180002 0.0344977 0.0344766 0.912143
##  30:     4180.9145: 0.0114051 -0.128679 0.179729 0.0186784 0.0347649 0.0367378 0.909781
##  31:     4180.8614: 0.0120147 -0.0981896 0.148996 0.0186760 0.0350652 0.0374611 0.907772
##  32:     4180.6286: 0.0167261 -0.146222 0.195989 0.0160406 0.0423852 0.0262607 0.914594
##  33:     4179.9863: 0.0278852 -0.108362 0.160499 0.0179731 0.0452981 0.0268463 0.909684
##  34:     4179.8759: 0.0389712 -0.201948 0.254826 0.0190505 0.0349392 0.0366266 0.908425
##  35:     4179.7971: 0.0401254 -0.153606 0.203991 0.0186412 0.0361799 0.0364379 0.908242
##  36:     4179.7723: 0.0387613 -0.153286 0.204185 0.0186518 0.0387350 0.0342847 0.907902
##  37:     4179.7712: 0.0380231 -0.145066 0.196369 0.0185615 0.0395751 0.0330278 0.908373
##  38:     4179.7707: 0.0379510 -0.149362 0.200467 0.0185766 0.0395148 0.0333839 0.908112
##  39:     4179.7706: 0.0380834 -0.148776 0.199910 0.0185871 0.0394370 0.0334200 0.908129
##  40:     4179.7706: 0.0380611 -0.148700 0.199835 0.0185843 0.0394510 0.0334001 0.908138
##  41:     4179.7706: 0.0380622 -0.148710 0.199845 0.0185846 0.0394502 0.0334020 0.908137
## 
## Final Estimate of the Negative LLH:
##  LLH:  -7695.869    norm LLH:  -2.437716 
##            mu           ar1           ma1         omega        alpha1 
##  8.847391e-04 -1.487097e-01  1.998448e-01  1.004141e-05  3.945024e-02 
##        alpha2         beta1 
##  3.340199e-02  9.081366e-01 
## 
## R-optimhess Difference Approximated Hessian Matrix:
##                   mu           ar1           ma1         omega
## mu      -5804399.013 -3.054037e+03  1.286124e+03 -5.248985e+07
## ar1        -3054.037 -3.052770e+03 -3.071717e+03 -1.265958e+06
## ma1         1286.124 -3.071717e+03 -3.117684e+03 -1.186777e+06
## omega  -52489849.142 -1.265958e+06 -1.186777e+06 -1.454973e+12
## alpha1      1319.787  6.021266e+01  5.899689e+01 -3.943726e+08
## alpha2     -7751.153 -3.789274e+01 -3.491994e+01 -3.932371e+08
## beta1     -28331.208 -5.595683e+02 -5.343574e+02 -5.055202e+08
##               alpha1        alpha2         beta1
## mu      1.319787e+03 -7.751153e+03 -2.833121e+04
## ar1     6.021266e+01 -3.789274e+01 -5.595683e+02
## ma1     5.899689e+01 -3.491994e+01 -5.343574e+02
## omega  -3.943726e+08 -3.932371e+08 -5.055202e+08
## alpha1 -1.605027e+05 -1.591281e+05 -1.736106e+05
## alpha2 -1.591281e+05 -1.612429e+05 -1.754598e+05
## beta1  -1.736106e+05 -1.754598e+05 -2.079402e+05
## attr(,"time")
## Time difference of 0.11092 secs
## 
## --- END OF TRACE ---
## 
## 
## Time to Estimate Parameters:
##  Time difference of 0.396312 secs
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~arma(1, 1) + garch(2, 1), data = d.series.name, 
##     include.mean = TRUE) 
## 
## Mean and Variance Equation:
##  data ~ arma(1, 1) + garch(2, 1)
## <environment: 0x7fd99e4b3208>
##  [data = d.series.name]
## 
## Conditional Distribution:
##  norm 
## 
## Coefficient(s):
##          mu          ar1          ma1        omega       alpha1  
##  8.8474e-04  -1.4871e-01   1.9984e-01   1.0041e-05   3.9450e-02  
##      alpha2        beta1  
##  3.3402e-02   9.0814e-01  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##          Estimate  Std. Error  t value Pr(>|t|)    
## mu      8.847e-04   4.451e-04    1.988 0.046835 *  
## ar1    -1.487e-01   2.080e-01   -0.715 0.474662    
## ma1     1.998e-01   2.058e-01    0.971 0.331439    
## omega   1.004e-05   2.712e-06    3.702 0.000214 ***
## alpha1  3.945e-02   1.738e-02    2.270 0.023202 *  
## alpha2  3.340e-02   2.103e-02    1.588 0.112285    
## beta1   9.081e-01   1.456e-02   62.383  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  7695.869    normalized:  2.437716 
## 
## Description:
##  Tue Nov 17 21:00:22 2015 by user:  
## 
## 
## Standardised Residuals Tests:
##                                 Statistic p-Value     
##  Jarque-Bera Test   R    Chi^2  158.6731  0           
##  Shapiro-Wilk Test  R    W      0.9921676 4.212096e-12
##  Ljung-Box Test     R    Q(10)  12.27084  0.2673392   
##  Ljung-Box Test     R    Q(15)  24.79349  0.05278648  
##  Ljung-Box Test     R    Q(20)  27.02037  0.1346918   
##  Ljung-Box Test     R^2  Q(10)  11.04974  0.3536558   
##  Ljung-Box Test     R^2  Q(15)  14.87996  0.4600981   
##  Ljung-Box Test     R^2  Q(20)  16.74909  0.6692009   
##  LM Arch Test       R    TR^2   12.86545  0.3788956   
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -4.870997 -4.857566 -4.871007 -4.866178